package com.stormrage.edu.dao.exam.impl;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.stormrage.edu.dao.exam.ExmScorePercentDao;
import com.stormrage.entity.exam.ExmScorePercent;
import com.stormragetech.core.dao.MysBaseDao;
import com.stormragetech.core.exception.StormrageTechException;

/**
 * @Title: ExamScorePercentDaoImpl.java
 * @Package com.stormrage.edu.dao.exam.impl
 * @Description: 专业各项分数百分比
 * @author www.stormragetech.com
 * @date 2016年4月22日
 * @version V1.0
 */
@Repository
public class ExmScorePercentDaoImpl extends MysBaseDao implements ExmScorePercentDao {

	private static final Logger logger = LoggerFactory.getLogger(ExmScorePercentDaoImpl.class);

	@Override
	public Integer create(final ExmScorePercent arg0) throws StormrageTechException {

		logger.debug(" 【 Dao 】-【 ExamScorePercentDao 】-【 Create 】- 开始运行 ");

		final String query = "INSERT INTO exm_score_percent (term_id, exam, oper, usua) VALUES"
				+ " (:termId, :exam, :oper, :usua)";
		logger.debug(" 数据库执行语句为 " + query);

		Integer index = create(query, arg0);

		logger.debug(" 【 Dao 】-【 ExamScorePercentDao 】-【 Create 】- 完成运行 ");
		return index;

	}

	@Override
	public void update(final ExmScorePercent arg0) throws StormrageTechException {

		logger.debug(" 【 Dao 】-【 ExamScorePercentDao 】-【 update 】- 开始运行 ");

		final String query = "UPDATE exm_score_percent SET exam = :exam, oper = :oper, usua = :usua WHERE id = :id";
		logger.debug(" 数据库执行语句为 " + query);

		update(query, arg0);

		logger.debug(" 【 Dao 】-【 ExamScorePercentDao 】-【 update 】- 完成运行 ");

	}

	@Override
	public ExmScorePercent queryById(final Map<String, Object> map) throws StormrageTechException {

		logger.debug(" 【 Dao 】-【 ExamScorePercentDao 】-【 queryById 】- 开始运行 ");

		final String query = "SELECT * FROM exm_score_percent WHERE id = :id";
		logger.debug(" 数据库执行语句为 " + query);

		ExmScorePercent entity = queryObject(query, ExmScorePercent.class, map);

		logger.debug(" 【 Dao 】-【 ExamScorePercentDao 】-【 queryById 】- 完成运行 ");
		return entity;

	}

	@Override
	public ExmScorePercent queryByTermId(final Map<String, Object> map) throws StormrageTechException {

		logger.debug(" 【 Dao 】-【 ExamScorePercentDao 】-【 queryByTermId 】- 开始运行 ");

		final String query = "SELECT * FROM exm_score_percent WHERE term_id = :termId";
		logger.debug(" 数据库执行语句为 " + query);

		ExmScorePercent entity = queryObject(query, ExmScorePercent.class, map);

		logger.debug(" 【 Dao 】-【 ExamScorePercentDao 】-【 queryByTermId 】- 完成运行 ");
		return entity;

	}

}
